package com.gyb.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ConsumerController {
	
	@Autowired
	private RestTemplate restTemplate;
	
    @GetMapping("/{id}")
    public String get(@PathVariable int id){
    	
    	//appServiceA为被调用服务的应用名，这里相当于vip的作用，ribbon走负载均衡
    	String obj = this.restTemplate.getForObject("http://appServiceA/"+id, String.class);
    	
        return obj.toString();
    }
}
